package ModelLayer;
import java.util.ArrayList;

public class SalesOrder 
{
	private int saleId;
	private String orderType;
	private String date;
	private String deliveryStatus;
	private String deliveryDate;
	private Customer customer;
	private Employee employee;
	private ArrayList<SalesOrderLine> sols;
	private Invoice invoice;
	
	//Constructor which takes; saleId, ordertype, date, deliverystatus, deliverydate, customer, employee and invoice as a parameter.
	public SalesOrder(int saleId, String orderType, String date, String deliveryStatus, String deliveryDate, Customer customer, Employee employee, Invoice invoice)
	{
		this.saleId = saleId;
		this.orderType = orderType;
		this.date = date;
		this.deliveryStatus = deliveryStatus;
		this.deliveryDate = deliveryDate;
		this.customer = customer;
		this.employee = employee;
		sols = new ArrayList<SalesOrderLine>();
		this.invoice = invoice;
	}
	
	//Empty constructor
	public SalesOrder()
	{
		sols = new ArrayList<SalesOrderLine>();;
	}

	//Returns saleid
	public int getSaleId() 
	{
		return saleId;
	}

	//Sets saleID
	public void setSaleId(int saleId) 
	{
		this.saleId = saleId;
	}
	
	//Returns ordertype
	public String getOrderType() 
	{
		return orderType;
	}

	//Sets Ordertype
	public void setOrderType(String orderType) 
	{
		this.orderType = orderType;
	}

	//Returns date
	public String getDate() 
	{
		return date;
	}

	//Sets the order date
	public void setDate(String date) 
	{
		this.date = date;
	}

	//Returns deliverystatus
	public String getDeliveryStatus() 
	{
		return deliveryStatus;
	}

	//Sets the delivery status
	public void setDeliveryStatus(String deliveryStatus) 
	{
		this.deliveryStatus = deliveryStatus;
	}

	//Returns delivery date
	public String getDeliveryDate() 
	{
		return deliveryDate;
	}

	//Sets the delivery date
	public void setDeliveryDate(String deliveryDate) 
	{
		this.deliveryDate = deliveryDate;
	}

	//Returns Customer
	public Customer getCustomer() 
	{
		return customer;
	}

	//Sets the customer
	public void setCustomer(Customer customer) 
	{
		this.customer = customer;
	}
	
	//Returns Employee
	public Employee getEmployee()
	{
		return employee;
	}
	
	//Sets the employee
	public void setEmployee(Employee employee)
	{
		this.employee = employee;
	}
	
	//Adds the Sales Order Line Array
	public void addSOLArray(ArrayList<SalesOrderLine> sol)
	{
		this.sols = sol;
	}
	
	//Adds a sales order line
	public void addSOL(SalesOrderLine sol)
	{
		sols.add(sol);
	}
	
	//Returns number om sales order lines
	public void getNumberOfSOLS()
	{
		System.out.println(sols.size());
	}
	
	//Returns Invoice
	public Invoice getInvoice()
	{
		return invoice;
	}
	
	//Sets Invoice
	public void setInvoice(Invoice invoice)
	{
		this.invoice = invoice;
	}
	
	//Calculates the total price
	public double setTotalPrice()
	{
		double totalPrice = 0;
		for(SalesOrderLine salesOrderLine : sols)
		{
			totalPrice = salesOrderLine.getTotalPrice() + totalPrice;
		}
		return totalPrice;
	}
	
	//Returns sales order lines
	public ArrayList<SalesOrderLine> getSols() 
	{
		return sols;
	}
}